﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Security.Application;
using ThreeDPrinting.ORM;

namespace ThreeDPrinting
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (DBEntities entities = new DBEntities())
            {
                tblmember mem = new tblmember();
                int sessionID = Convert.ToInt32(Session["memberID"]);
                mem = entities.tblmembers.SingleOrDefault(p => p.memberID == sessionID);
                if (Session["memberID"] != null)
                {
                    lblWelcome.Text = "Welcome: " + mem.memberUserName.ToString();
                    btnLogOut.Visible = true;
                    btnLogOut.Enabled = true;
                    login.Visible = false;
                    join.Visible = false;
                }
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ////TextBox1.Text = "before <script>alert('hello')</script> after ";

            //string cleanText = Sanitizer.GetSafeHtmlFragment(TextBox1.Text);
            //string decode = HttpUtility.HtmlDecode(cleanText);
            //string trimmed = (cleanText == null) ? null : cleanText.Trim();
            //trimmed = trimmed.ToUpper();

            //if (trimmed != null)
            //{
            //    switch (trimmed)
            //    {
            //        case "JOE":
            //            Session["memberID"] = "1";
            //            break;
            //        case "STEVE":
            //            Session["memberID"] = "2";
            //            break;
            //    }
            //    if (Session["memberID"] != null)
            //        lblWelcome.Text = "Member ID: " + Session["memberID"].ToString();
            //}
        }

        protected void btnLogOut_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("~/Pages/LogIn");
        }
    }
}